package com.bird.file.propertie;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Set;

/**
 * @author sijunqiang
 * @data 2021/8/1 10:11
 * @description: 属性集 专门用来获取系统的属性
 */
public class Properties {

    //- public void load(InputStream in)： 从字节输入流中读取属性文件。
    //- public void load(Reader reader): 从字符流中读取属性文件存入到流中
    //- public void store(OutputStream out,String comment): comment是注释
    //- public void store(Writer writer, String comment):

    public static void main(String[] args) throws IOException {
        java.util.Properties properties = System.getProperties();
        System.out.println(properties.toString());
        // 创建属性集对象
        java.util.Properties pro = new java.util.Properties();
        // 加载文本中信息到属性集
        pro.load(new FileInputStream("read.txt"));
        // 遍历集合并打印
        Set<String> strings = pro.stringPropertyNames();
        for (String key : strings) {
            System.out.println(key + " -- " + pro.getProperty(key));
        }
    }
}




